using System.Collections.Generic;

namespace Sinacor.Servico.Bovespa.Contabil.Service.ServiceImplementation.Translator.DataContractToBusinessEntity
{
    public class DespesaNota 
    {

		public DespesaNota(){}

		public BusinessEntity.DespesaNota ToDespesaNota(DataContract.Request.DespesaNotaRequest request)
        {
            BusinessEntity.DespesaNota to = new Sinacor.Servico.Bovespa.Contabil.BusinessEntity.DespesaNota();
            to.BaseDespesa = (BusinessEntity.Enum.TipoBaseDespesa) request.BaseDespesa;
            to.Codigo = request.Codigo;

            if (request.EventoContabil != null)
            {
                to.EventoContabil = new Sinacor.Servico.Bovespa.Contabil.BusinessEntity.EventoContabil();
                to.EventoContabil.Codigo = request.EventoContabil.Codigo; 
                to.EventoContabil.Descricao = request.EventoContabil.Descricao;
            }
            
            to.IncideIrrf = request.IncideIrrf;
            to.PercentualDespesa = request.PercentualDespesa;
            to.PregaoFinal = request.PregaoFinal;
            to.PregaoInicial = request.PregaoInicial;
            to.ValorMaximo = request.ValorMaximo;
            to.ValorMinimo = request.ValorMinimo; 
            return to;
		}

		public List<BusinessEntity.DespesaNota> ToDespesaNota(List<DataContract.Request.DespesaNotaRequest> requestList)
        {
            List<BusinessEntity.DespesaNota> to = new List<Sinacor.Servico.Bovespa.Contabil.BusinessEntity.DespesaNota>();
            foreach(DataContract.Request.DespesaNotaRequest item in requestList)
            {
                to.Add(ToDespesaNota(item));
            }
			return to;
		}

		public BusinessEntity.Parameter.FiltroDespesaNota ToFiltroDespesaNota(DataContract.Request.FiltroDespesaNotaRequest request)
        {
            BusinessEntity.Parameter.FiltroDespesaNota to = new Sinacor.Servico.Bovespa.Contabil.BusinessEntity.Parameter.FiltroDespesaNota();
            to.BaseDespesa = (BusinessEntity.Enum.TipoBaseDespesa?) request.BaseDespesa;
            to.Codigo = request.Codigo;
            to.EventoContabil = request.EventoContabil;
            to.IncideIrrf = request.IncideIrrf;
            to.PercentualDespesa = request.PercentualDespesa;
            to.PregaoFinal = request.PregaoFinal;
            to.PregaoInicial = request.PregaoInicial;
            to.ValorMaximo = request.ValorMaximo;
            to.ValorMinimo = request.ValorMinimo; 
            return to;
		}

		public List<BusinessEntity.Parameter.FiltroDespesaNota> ToFiltroDespesaNota(List<DataContract.Request.FiltroDespesaNotaRequest> requestList)
        {
            List<BusinessEntity.Parameter.FiltroDespesaNota> to = new List<Sinacor.Servico.Bovespa.Contabil.BusinessEntity.Parameter.FiltroDespesaNota>();
            foreach(DataContract.Request.FiltroDespesaNotaRequest item in requestList)
            {
                to.Add(ToFiltroDespesaNota(item));
            }
			return to;
		}

		public BusinessEntity.Parameter.FiltroDespesaNotaChave ToFiltroDespesaNotaChave(DataContract.Request.FiltroDespesaNotaChaveRequest request)
        {
            BusinessEntity.Parameter.FiltroDespesaNotaChave to = new Sinacor.Servico.Bovespa.Contabil.BusinessEntity.Parameter.FiltroDespesaNotaChave();
            to.Codigo = request.Codigo;
            to.PregaoInicial = request.PregaoInicial;
			return to;
		}

		public List<BusinessEntity.Parameter.FiltroDespesaNotaChave> ToFiltroDespesaNotaChave(List<DataContract.Request.FiltroDespesaNotaChaveRequest> requestList)
        {
            List<BusinessEntity.Parameter.FiltroDespesaNotaChave> to = new List<Sinacor.Servico.Bovespa.Contabil.BusinessEntity.Parameter.FiltroDespesaNotaChave>();
            foreach(DataContract.Request.FiltroDespesaNotaChaveRequest item in requestList)
            {
                to.Add(ToFiltroDespesaNotaChave(item));
            }
			return to;
		}
	}
}